<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="cd-parser-objects.html" />
<link rel="prev" href="module-cd.html" />
<link rel="parent" href="module-cd.html" />
<link rel="next" href="cd-parser-objects.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>34.3.1 Player Objects</title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="34.3 cd  "
  href="module-cd.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="34.3 cd  "
  href="module-cd.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="34.3.2 parser Objects"
  href="cd-parser-objects.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-cd.html">34.3 cd  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-cd.html">34.3 cd  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="cd-parser-objects.html">34.3.2 Parser Objects</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h2><a name="SECTION0036310000000000000000"></a>
<a name="player-objects"></a>
<br>
34.3.1 Player Objects
</h2>

<p>
Player objects (returned by <tt class="function">open()</tt>) have the following
methods:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5599' xml:id='l2h-5599' class="method">allowremoval</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Unlocks the eject button on the CD-ROM drive permitting the user to
eject the caddy if desired.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5600' xml:id='l2h-5600' class="method">bestreadsize</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns the best value to use for the <var>num_frames</var> parameter of
the <tt class="method">readda()</tt> method.  Best is defined as the value that
permits a continuous flow of data from the CD-ROM drive.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5601' xml:id='l2h-5601' class="method">close</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Frees the resources associated with the player object.  After calling
<tt class="method">close()</tt>, the methods of the object should no longer be used.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5602' xml:id='l2h-5602' class="method">eject</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Ejects the caddy from the CD-ROM drive.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5603' xml:id='l2h-5603' class="method">getstatus</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Returns information pertaining to the current state of the CD-ROM
drive.  The returned information is a tuple with the following values:
<var>state</var>, <var>track</var>, <var>rtime</var>, <var>atime</var>, <var>ttime</var>,
<var>first</var>, <var>last</var>, <var>scsi_audio</var>, <var>cur_block</var>.
<var>rtime</var> is the time relative to the start of the current track;
<var>atime</var> is the time relative to the beginning of the disc;
<var>ttime</var> is the total time on the disc.  For more information on
the meaning of the values, see the man page <span class="manpage"><i>CDgetstatus</i>(3dm)</span>.
The value of <var>state</var> is one of the following: <tt class="constant">ERROR</tt>,
<tt class="constant">NODISC</tt>, <tt class="constant">READY</tt>, <tt class="constant">PLAYING</tt>,
<tt class="constant">PAUSED</tt>, <tt class="constant">STILL</tt>, or <tt class="constant">CDROM</tt>.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5604' xml:id='l2h-5604' class="method">gettrackinfo</tt></b>(</nobr></td>
  <td><var>track</var>)</td></tr></table></dt>
<dd>
Returns information about the specified track.  The returned
information is a tuple consisting of two elements, the start time of
the track and the duration of the track.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5605' xml:id='l2h-5605' class="method">msftoblock</tt></b>(</nobr></td>
  <td><var>min, sec, frame</var>)</td></tr></table></dt>
<dd>
Converts a minutes, seconds, frames triple representing a time in
absolute time code into the corresponding logical block number for the
given CD-ROM drive.  You should use <tt class="function">msftoframe()</tt> rather than
<tt class="method">msftoblock()</tt> for comparing times.  The logical block number
differs from the frame number by an offset required by certain CD-ROM
drives.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5606' xml:id='l2h-5606' class="method">play</tt></b>(</nobr></td>
  <td><var>start, play</var>)</td></tr></table></dt>
<dd>
Starts playback of an audio CD in the CD-ROM drive at the specified
track.  The audio output appears on the CD-ROM drive's headphone and
audio jacks (if fitted).  Play stops at the end of the disc.
<var>start</var> is the number of the track at which to start playing the
CD; if <var>play</var> is 0, the CD will be set to an initial paused
state.  The method <tt class="method">togglepause()</tt> can then be used to commence
play.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5607' xml:id='l2h-5607' class="method">playabs</tt></b>(</nobr></td>
  <td><var>minutes, seconds, frames, play</var>)</td></tr></table></dt>
<dd>
Like <tt class="method">play()</tt>, except that the start is given in minutes,
seconds, and frames instead of a track number.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5608' xml:id='l2h-5608' class="method">playtrack</tt></b>(</nobr></td>
  <td><var>start, play</var>)</td></tr></table></dt>
<dd>
Like <tt class="method">play()</tt>, except that playing stops at the end of the
track.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5609' xml:id='l2h-5609' class="method">playtrackabs</tt></b>(</nobr></td>
  <td><var>track, minutes, seconds, frames, play</var>)</td></tr></table></dt>
<dd>
Like <tt class="method">play()</tt>, except that playing begins at the specified
absolute time and ends at the end of the specified track.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5610' xml:id='l2h-5610' class="method">preventremoval</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Locks the eject button on the CD-ROM drive thus preventing the user
from arbitrarily ejecting the caddy.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5611' xml:id='l2h-5611' class="method">readda</tt></b>(</nobr></td>
  <td><var>num_frames</var>)</td></tr></table></dt>
<dd>
Reads the specified number of frames from an audio CD mounted in the
CD-ROM drive.  The return value is a string representing the audio
frames.  This string can be passed unaltered to the
<tt class="method">parseframe()</tt> method of the parser object.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5612' xml:id='l2h-5612' class="method">seek</tt></b>(</nobr></td>
  <td><var>minutes, seconds, frames</var>)</td></tr></table></dt>
<dd>
Sets the pointer that indicates the starting point of the next read of
digital audio data from a CD-ROM.  The pointer is set to an absolute
time code location specified in <var>minutes</var>, <var>seconds</var>, and
<var>frames</var>.  The return value is the logical block number to which
the pointer has been set.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5613' xml:id='l2h-5613' class="method">seekblock</tt></b>(</nobr></td>
  <td><var>block</var>)</td></tr></table></dt>
<dd>
Sets the pointer that indicates the starting point of the next read of
digital audio data from a CD-ROM.  The pointer is set to the specified
logical block number.  The return value is the logical block number to
which the pointer has been set.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5614' xml:id='l2h-5614' class="method">seektrack</tt></b>(</nobr></td>
  <td><var>track</var>)</td></tr></table></dt>
<dd>
Sets the pointer that indicates the starting point of the next read of
digital audio data from a CD-ROM.  The pointer is set to the specified
track.  The return value is the logical block number to which the
pointer has been set.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5615' xml:id='l2h-5615' class="method">stop</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Stops the current playing operation.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-5616' xml:id='l2h-5616' class="method">togglepause</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
Pauses the CD if it is playing, and makes it play if it is paused.
</dl>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="34.3 cd  "
  href="module-cd.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="34.3 cd  "
  href="module-cd.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="34.3.2 parser Objects"
  href="cd-parser-objects.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-cd.html">34.3 cd  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-cd.html">34.3 cd  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="cd-parser-objects.html">34.3.2 Parser Objects</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
